package com.fifth.commodity.controller;

import com.fifth.commodity.service.SortService;
import com.fifth.commodity.vo.SortVo;
import com.fifth.commodity.vo.StateVo;
import com.fifth.common.pojo.dto.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("commodity/sort")
public class SortController {
    @Autowired
    private SortService sortService;

    /**
     * 查询所有商品类型
     * @return
     */
    @ApiOperation(value = "查找所有商品类型")
    @GetMapping("findAllSort")
    public CommonResult findAllSort(){
       return sortService.findAllSort();
    }

    /**
     * 根据条件分页查询所有类别信息
     * @param pageCurrent
     * @param pageSize
     * @param sortVo
     * @return
     */
    @ApiOperation("根据条件分页查询所有类别信息")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "int",name = "pageCurrent",value = "页码数"),
            @ApiImplicitParam(dataType = "int",name = "pageSize",value = "每页显示个数"),
            @ApiImplicitParam(dataType = "SortVo",name = "sortVo",value = "查询条件"),
    })
    @PostMapping("findSortByCondition/{pageCurrent}/{pageSize}")
    public CommonResult findSortByCondition(@PathVariable Integer pageCurrent, @PathVariable Integer pageSize, @RequestBody SortVo sortVo){
        return sortService.findSortByCondition(pageCurrent,pageSize,sortVo);
    }

    /**
     * 根据id逻辑删除类别
     * @param id
     * @return
     */
    @ApiOperation(value = "根据id逻辑删除类别")
    @ApiImplicitParam(dataType = "int",name = "id",value = "类别id")
    @PostMapping("deleteSort")
    public CommonResult deleteSort(Integer id){
        return sortService.deleteSort(id);
    }

    /**
     * 修改类别的审核状态
     * @param stateVo
     * @return
     */
    @ApiOperation("修改类别的审核状态")
    @ApiImplicitParam(dataType = "StateVo",name = "stateVo",value = "接收审核信息的实体类")
    @PostMapping("updateStatus")
    public CommonResult updateStatus(@RequestBody StateVo stateVo){
        return sortService.updateStatus(stateVo);
    }


}
